Ext.ns('Ext.ux');
/**
 * Ext.ux.SrollerTools plugins for Ext.Panel and its subclasses A tools that
 * provide scroll for top toolbar Compatible with Ext Js 2.1 - 2.3 Support
 * browsers: Firefox 5, IE 8, Opera 11 and Coogle Chrome 11
 * 
 * @author liwen
 * @date 7 15, 2010
 * @version 0.0.0
 * 
 * @class Ext.ux.SrollerTools
 * @extends Ext.util.Observable
 */
Ext.ux.SrollerTools = Ext.extend(Ext.util.Observable, {
    init: function(panel) {
		
    },
    renderToolbar: function(panel) {
       
    },
    renderButton: function(toolbar, dir) {
        
    }
});
var previousClick=null
Ext.ux.DynamicTbar= Ext.extend(Ext.Toolbar.Button , {
	
	initComponent : function() {
		var _this=this;
		var config = {		
			handler : function(_this) {
				
				
//			if(this.id!==previousClick||previousClick===null){	
				var _actionType = _this.actionType;
				if(_actionType===Global.ACTION_TYPE_RELOAD){
						_this.setCls();
							var tree = Ext.getCmp(Global.STD_WEST_MENU.id);
// tree.body.mask("Loading...","x-mask-loading");
					  setTimeout(function() {       
				
								tree.getLoader().dataUrl = _this.action;
								tree.getLoader().load(tree.root);},300);
								
					
						
				}
						
				switch (_actionType) {
					case Global.ACTION_TYPE_RELOAD :
						break;
					case Global.ACTION_TYPE_ADD:
						_this.newForm(_this.action,_this.id,_this.ownerCt.ownerCt,Global.ACTION_TYPE_ADD);
						break;
					case Global.ACTION_TYPE_EDIT:
						var _thisCt = _this.getOwnerCt(_this);
						_this.editForm(_this.action,_this.id,_thisCt,Global.ACTION_TYPE_EDIT);
						break;
					case Global.ACTION_TYPE_DELETE :
						var _thisCt = _this.getOwnerCt(_this);
						_this.batchForm(_this.action,_this.id,_thisCt,Global.ACTION_TYPE_DELETE);
						break;
					// 查看详情
					case 'detail' :
						var _thisCt = _this.getOwnerCt(_this);
						_this.viewForm(_this.action,_this.id,_thisCt,'detail');
						break;						
					// 文章管理
					case "articleAdd" :
						_this.articleForm(_this.action,_this.id,_this.ownerCt.ownerCt,"articleAdd");
						break;
					case "articleEdit" :
						_this.articleForm(_this.action,_this.id,_this.ownerCt.ownerCt,"articleEdit");
						break;
					case "articleArchiveEdit" :
						_this.articleForm(_this.action,_this.id,_this.ownerCt.ownerCt,"articleArchiveEdit");
						break;
					case "articleKeyFilterEdit" :
						_this.articleForm(_this.action,_this.id,_this.ownerCt.ownerCt,"articleKeyFilterEdit");
						break;		
					case "articleDelete" :
						_this.articleForm(_this.action,_this.id,_this.ownerCt.ownerCt,"articleDelete");
						break;
					// 文章预览
					case "articlepreview" :
						_this.articleForm(_this.action,_this.id,_this.ownerCt.ownerCt,"articlepreview");
						break;
					// 文章调用模拟器预览
					case "articlePreviewHdByMonitor" :
						_this.articleForm(_this.action,_this.id,_this.ownerCt.ownerCt,"articlePreviewHdByMonitor");
						break;
					case "articlePreviewSdByMonitor" :
						_this.articleForm(_this.action,_this.id,_this.ownerCt.ownerCt,"articlePreviewSdByMonitor");
						break;
						
					// 发送审核
					case "articleSendAudit" :
						var _thisCt = _this.getOwnerCt(_this);
						_this.articleAudit(_this.action,_this.id,_thisCt,"articleSendAudit");
						break;
					// 推荐
					case "articleCommend" :
						var _thisCt = _this.getOwnerCt(_this);
						_this.articleAudit(_this.action,_this.id,_thisCt,"articleCommend");
						break;
					// 属性配置
					case "addinviewcfg" :
						_this.configAddForm(_this.action,_this.id,_this.ownerCt.ownerCt,"addinviewcfg");
						break;
					// 栏目模拟器预览
					case "channelPreviewHdByMonitor" :
						_this.channelForm(_this.action,_this.id,_this.ownerCt.ownerCt,"channelPreviewHdByMonitor");
						break;	
					case "channelPreviewSdByMonitor" :
						_this.channelForm(_this.action,_this.id,_this.ownerCt.ownerCt,"channelPreviewSdByMonitor");
						break;
					// 栏目新增
					case "addChannel" :
						_this.channelForm(_this.action,_this.id,_this.ownerCt.ownerCt,"addChannel");
						break;
					// 栏目修改
					case "editChannel" :
						_this.channelForm(_this.action,_this.id,_this.ownerCt.ownerCt,"editChannel");
						break;
					// 模板导入
					case "importTemplate" :
						_this.importTemplate(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					// 模板 上传
					case "uploadImage" :
						_this.importTemplate(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;						
					// 模板导出
					case "exportTemplate" :
						_this.exportTemplate(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					// 列表导出
					case 'exportList' :
						_this.exportList(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					// 模板预览
					case "viewTemplate" :
						var _thisCt = _this.getOwnerCt(_this);
						_this.viewTemplate(_this.action,_this.id,_thisCt);
						break;
					// 推荐/取消
					case "recommand" :
						var _thisCt = _this.getOwnerCt(_this);
						_this.recommandTemplate(_this.action,_this.id,_thisCt);
						break;
					// 屏蔽/开启
					case "openClose" :
						var _thisCt = _this.getOwnerCt(_this);
						_this.recommandTemplate(_this.action,_this.id,_thisCt);
						break;
						// 新增角色
				    case "roleAdd" :
						_this.roleWin(_this.action,_this.id,_this.ownerCt.ownerCt,"roleAdd");
						break;
						// 修改角色
				    case "roleEdit" :
						_this.roleWin(_this.action,_this.id,_this.ownerCt.ownerCt,"roleEdit");
						break;
						
					case "batchAudit" ://批量审核
						var _thisCt = _this.getOwnerCt(_this);
						_this.batchForm(_this.action,_this.id,_thisCt,"batchAudit");
						break;
						
					case "batchAuditReject" ://批量审核
						var _thisCt = _this.getOwnerCt(_this);
						_this.batchForm(_this.action,_this.id,_thisCt,"batchAuditReject");
						break;
						
					case "grid" ://查看审核流程
						var _thisCt = _this.getOwnerCt(_this);
						_this.grid(_this.action,_this.id,_thisCt,"grid");
						break;
							
					case "audit" ://审核
						_this.audit(_this.action,_this.id,_this.ownerCt.ownerCt,"audit");
						break;
						
					case "openURL" ://打开连接
					_this.openURL(_this.action,_this.id,_this.ownerCt.ownerCt,"openURL");
					break;	
						
					case "viewAuditContent" ://查看审核意见
						_this.audit(_this.action,_this.id,_this.ownerCt.ownerCt,"viewAuditContent");
						break;
					case "releaseTime" ://定时发布设置
						_this.releaseTime(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					case "gridCommit" ://提交grid里面的所有record的数据
						_this.gridCommit(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					case "showShourCut" ://设置桌面快捷方式
						_this.showShourCut();
						break;	
					//
					case "startSkin" :
						_this.startSkin(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					case "exportSkin" :
						_this.exportSkin(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					case "SnatchWeather" :
						_this.SnatchWeather(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					case "SnatchWeatherByCity" :
						_this.SnatchWeatherByCity(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					case "SnatchCityIconByCity" :
						_this.SnatchCityIconByCity(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;	
						
					// 模板导出
					case "download" :
						_this.download(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;			
					// 带参数的导出
					case "downloadByParam" :
						_this.downloadByParam(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;		
					// 一对多
					case "childmanage" :
						var _thisCt = _this.getOwnerCt(_this);
						_this.childmanage(_this.action,_this.id,_thisCt);
						break;						
					// 一对多 新增建立关联
					case "addbyselect" :
						_this.addbyselect(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;		
					// 模拟器预览
					case 'previewByMonitor' :
						_this.previewByMonitor(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					// 模拟器预览，带参数
					case 'previewByMonitorWithParam' :
						_this.previewByMonitorWithParam(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					// 上下移动排序
					case 'rowUp' : 
						_this.rowUp(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					case 'rowDown' :
						_this.rowDown(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					case 'rowTop' :
						_this.rowTop(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					case 'rowBottom' :
						_this.rowBottom(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					// 同步
					case 'syn' : 
						_this.syn(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					case 'quickAddEdit' : 
					    _this.quickAddEdit(_this.action,_this.id,_this.ownerCt.ownerCt);
					    break;
					// 电视信箱登录
					case 'login' :
					    _this.login(_this.action,_this.id,_this.ownerCt.ownerCt);
					    break;
					// 电视信箱退出
					case 'logout' :
					    _this.logout(_this.action,_this.id,_this.ownerCt.ownerCt);
					    break;	
					// 发布
					case 'publishBussiness' : _this.publishBussiness(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					// 批量向后台提交列表中选中的一条或多条数据
					case 'batchProcess' : _this.batchProcess(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					case 'transfer' :
						//获取表对象
						_this.transfer(_this.action,_this.id,_this.ownerCt.ownerCt);
						break;
					case 'fechtCoreStart':
						var _thisCt = _this.getOwnerCt(_this);
						_this.fechtCoreStart(_this.action,_this.id,_thisCt);
						break;
					default :
						break;
				}
//				})
// }
// previousClick=this.id;
			}
			
		};
				
		Ext.apply(this, config);
		Ext.apply(this.initialConfig, config);
		Ext.ux.DynamicTbar.superclass.initComponent.apply(this, arguments);		
	},
	
    newForm : function($action,$tbarId,$owner,$actionType){
    	/**
    	 * 判断$action中有没有配置按钮名称buttonTextFlag。
    	 * 如果有就把他提取出来，作为DynamicEditFormWindow的一个参数，
    	 * 实现动态配置按钮的名称
    	 */
    	var index = $action.lastIndexOf('buttonTextFlag');
    	var buttonTextFlag = '';
    	if(index != -1){
    		var urlParam = $action.substr(index);
    		var urlParamObj = Ext.urlDecode(urlParam);
    		if(typeof(urlParamObj) === 'object'){
	    		buttonTextFlag = urlParamObj.buttonTextFlag;
    		}
    	}
    	
    	var baseParams = {
    		tbarId:$tbarId
    	};
    	if($owner.params != undefined){
	    	var postParams  = {};
	    	var par = Ext.util.JSON.decode($owner.params);
	    	for(var p in par) {
	    		postParams[p] = Ext.util.JSON.encode(par[p]);
	    	}    	
    		Ext.apply(baseParams,postParams);
    	};
		Ext.Ajax.request({
			url     : $action, 
			method  : 'POST',
		    params  : baseParams,
			success : function($response){
		   	   //检查session是否过期
			   checkTimeOut($response);
				var responseObj = Ext.util.JSON.decode($response.responseText);
				if(responseObj.success){
						var _res        = Ext.decode($response.responseText);
						_res.record     = {};
						_res.tbarId     = $tbarId;
						_res.actionType = $actionType;
						var newWin = new VAS.DynamicEditFormWindow({
					        id      :  _res.win.id,
							title   :  _res.win.title,
							width   :  _res.win.width,
							height  :  _res.win.height,			
							data    :  _res,
							tbarId  :  $tbarId,
							grid    :  $owner,
							actionType   :  $actionType
							,buttonTextFlag : buttonTextFlag
						});
						newWin.show();	
				}else{
					alertFailure(responseObj);
				}
			},
			failure:function(){
				Ext.Msg.alert('提示','服务器异常！');
			}
		   });
		     this.callback();
	},
	

	editForm : function($action,$tbarId,$owner,$actionType) {			
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if (typeof(_records)==='object' && _records.length>1) {
	 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
	 		return;
	 	}
	 	var _postData    = {};
		_postData.items  = [];
		for (var i=0;i<_records.length;i++) {
			var  _record;
			_record=_records[i];		 
			_postData.items.push(_record.data);				
		}
	 	
 	 	Ext.Ajax.request({
 	   		 url:$action,
             success: function($response){
             	//检查session是否过期
			    checkTimeOut($response);
             	var responseObj = Ext.util.JSON.decode($response.responseText);
             	if(responseObj.success){
	                var editWin = new VAS.DynamicEditFormWindow({
				        id       : responseObj.win.id,
						title    : responseObj.win.title,
						width    : responseObj.win.width,
						height   : responseObj.win.height,			
						data     : responseObj,
						records  : _records,
						tbarId   : $tbarId,
						grid     :  $owner,
						actionType   :  $actionType
					});
					editWin.show();
             	}else{
             		alertFailure(responseObj);
             	}
             },
             failure:  function(){
				Ext.Msg.alert('提示','服务器异常！');
			}
             ,params:{tbarId:$tbarId,data:Ext.encode(_postData)}
         });
          this.callback();
	},	
	
	viewForm : function($action,$tbarId,$owner,$actionType) {
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if (typeof(_records)==='object' && _records.length>1) {
	 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
	 		return;
	 	}
	 	var _postData    = {};
		_postData.items  = [];
		for (var i=0;i<_records.length;i++) {
			var  _record;
			_record=_records[i];		 
			_postData.items.push(_record.data);				
		}
	 	
 	 	Ext.Ajax.request({
 	   		 url:$action,
             success: function($response){
             	//检查session是否过期
			    checkTimeOut($response);
             	var responseObj = Ext.util.JSON.decode($response.responseText);
             	if(responseObj.success){
	                var editWin = new VAS.DynamicEditFormWindow({
				        id       : responseObj.win.id,
						title    : responseObj.win.title,
						width    : responseObj.win.width,
						height   : responseObj.win.height,			
						data     : responseObj,
						records  : _records,
						tbarId   : $tbarId,
						grid     :  $owner,
						actionType   :  $actionType
					});
					editWin.show();
             	}else{
             		alertFailure(responseObj);
             	}
             },
             failure:  function(){
				Ext.Msg.alert('提示','服务器异常！');
			}
             ,params:{tbarId:$tbarId,data:Ext.encode(_postData)}
         });
          this.callback();
	},
	
	showWin : function(_data){
		var editWin = new VAS.DynamicEditFormWindow({
	    	id       : _data.win.id,
			title    : _data.win.title,
			width    : _data.win.width,
			height   : _data.win.height,			
			data     : _data,
			records  : _records,
			tbarId   : $tbarId
		});
		
		editWin.show();
		
		 this.callback();
		
	},
	
	batchForm : function($action,$tbarId,$owner,$actionType){
		var _records = $owner.getSelectionModel().getSelections();  
		var _postData   =  {};
		_postData.items =  [];
		var  _record;
		for(var i=0;i<_records.length;i++){
			_record=_records[i];		 
			_postData.items.push(_record.data);				
		}
		
		var msg;
		
		if($actionType== "batchAudit" ){
				msg="您确定审核通过吗?";
		}else if($actionType== "batchAuditReject"){
			msg="您确确定审核不通过吗?";
		}else{
			msg="您确实要删除数据吗?";	
		}
	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if(typeof(_records)==='object' && _records.length>=1){
			Ext.Msg.show({
				title : '提示',
				msg : msg,
				buttons : {yes:'是', no:'否'},
				fn : function(btn){
				    if (btn == 'yes'){
				        Ext.Ajax.request({
							url : $action,
							success : function(response, options) {
								//检查session是否过期
			    				checkTimeOut(response);
								var responseObj = Ext.util.JSON.decode(response.responseText);
								if(responseObj.success){
									if(responseObj.msg == '' || responseObj.msg == undefined){
										responseObj.msg = '成功';
									}
									//如果为删除，则不弹出成功提示
									if($actionType== "delete" ){
										$owner.store.reload();
										// 刷新左侧的菜单树
										var tree = Ext.getCmp(Global.STD_WEST_MENU.id);
										tree.getRootNode().reload();
										/**
										 * 增加栏目树的刷新 2010-07-27 by 903820
										 */
										var menu = session.get("channelMenu");
										if (typeof menu != undefined && menu != null) {
	        								menu.getRootNode().reload();
										}
									}else{
										Ext.MessageBox.alert('提示', responseObj.msg,function(bt){
											$owner.store.reload();
											// 刷新左侧的菜单树
											var tree = Ext.getCmp(Global.STD_WEST_MENU.id);
											tree.getRootNode().reload();
											/**
											 * 增加栏目树的刷新 2010-07-27 by 903820
											 */
											var menu = session.get("channelMenu");
											if (typeof menu != undefined && menu != null) {
		        								menu.getRootNode().reload();
											}
										});
									}
								}else{
									alertFailure(responseObj);
									$owner.store.reload();
								}
							},
							failure : function(response, options) {
								Ext.Msg.alert('提示','服务器异常！');
							},
							params:{tbarId:$tbarId,data:Ext.util.JSON.encode(_postData)}
						})
				   	}else{
				    	return;	
				   	}
				}
			});
	 	} 	
	 	this.callback();
	},
	
	/**
	 * 栏目新增
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */	
	channelForm : function($action,$tbarId,$owner,$actionType) {
		var storeUrl = $owner.store.url;
		var  title;
		var  loadUrl   = "admin/channel/ChannelAction!getBusinessAndChannel.action";
		var par = storeUrl.substring(storeUrl.lastIndexOf('?'),storeUrl.length);
		var  _records;
		var  isLoad = false;
		switch ($actionType) {
			case "addChannel"   :
				title = "新增栏目";
				loadUrl += par;
		        var win = new VAS.CategoryContentWindow({
			        id         : "channel_win",
					title      : title,
					width      : 900,
					height     : 610,
					layout	   : 'fit',
					draggable  : true,
					closable   : true,
					modal      : true,
					grid 	   : $owner,
					formUrl    : $action,
					loadUrl    : loadUrl,
					exParams   : par,
					actionType : $actionType
				});	
// win.manager = Ext.getCmp("std-panel").wgroup;
// Ext.WindowMgr.bringToFront(win);
				win.show();
				win.loadForm();		
				break;
			case "editChannel"  :
				$owner = this.getOwnerCt($owner);
			 	_records = $owner.getSelectionModel().getSelections();   	
			 	if (typeof(_records)==='undefined'||_records.length==0) {
			 		Ext.Msg.alert('提示','您没有选择数据');
			 		return;
			 	} else if (typeof(_records)==='object' && _records.length>1) {
			 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
			 		return;
			 	}
			 	
			 	var _postData    = {};
				_postData.items  = [];
				for (var i=0;i<_records.length;i++) {
					var  _record;
					_record=_records[i];		
					_postData.items.push(_record.data);				
				}			 	
				title     = "修改栏目";
				loadUrl   = "admin/channel/ChannelAction!getEditChannel.action";
		        var win = new VAS.CategoryContentWindow({
			        id         : "channel_win",
					title      : title,
					width      : 900,
					height     : 610,
					layout	   : 'fit',
					draggable  : true,
					closable   : true,
					modal      : true,
					grid 	   : $owner,
					formUrl    : $action,
					loadUrl    : loadUrl,
					exParams   : par,
					postData   : _postData,
					actionType : $actionType
				}).show();	
				win.loadForm();
				break;
			case "channelPreviewHdByMonitor"  :
				$owner = this.getOwnerCt($owner);
				_records = $owner.getSelectionModel().getSelections();   	
			 	if (typeof(_records)==='undefined'||_records.length==0) {
			 		Ext.Msg.alert('提示','您没有选择数据');
			 		return;
			 	} else if (typeof(_records)==='object' && _records.length>1) {
			 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
			 		return;
			 	}
				var _postData    = {};
				_postData = _records[0].data;
			  		    Ext.Ajax.request({
							   url    : 'admin/channel/ChannelAction!channelViewHdByMonitor.action',
							   method : "POST",
							   params : {id : _postData.id},					   
							   success: function(response) {
							   	   //检查session是否过期
			    				   checkTimeOut(response);
								   var responseObj = Ext.util.JSON.decode(response.responseText);
								   if(responseObj.success) {
									   eval(responseObj.msg);
								   } else {
								   		alertFailure(responseObj);
								   }
							   }, failure: function(response) {
									Ext.Msg.alert('提示','服务器异常！');
							   }
					   });	
			  	break;
			case "channelPreviewSdByMonitor"  :	
				_records = $owner.getSelectionModel().getSelections();   	
			 	if (typeof(_records)==='undefined'||_records.length==0) {
			 		Ext.Msg.alert('提示','您没有选择数据');
			 		return;
			 	} else if (typeof(_records)==='object' && _records.length>1) {
			 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
			 		return;
			 	}
				var _postData    = {};
				_postData = _records[0].data;
			  		    Ext.Ajax.request({
							   url    : 'admin/channel/ChannelAction!channelViewSdByMonitor.action',
							   method : "POST",
							   params : {id : _postData.id},					   
							   success: function(response) {
							       //检查session是否过期
			    				   checkTimeOut(response);
								   var responseObj = Ext.util.JSON.decode(response.responseText);
								   if(responseObj.success) {
									   eval(responseObj.msg);
								   } else {
								   		alertFailure(responseObj);
								   }
							   }, failure: function(response) {
									Ext.Msg.alert('提示','服务器异常！');
							   }
					   });	
			  	break;
			default :
				break;
		}

		 this.callback();	
	},	
	
	
	/**
	 * 文章管理  新增，修改，查看，模拟器预览
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */	
	articleForm : function($action,$tbarId,$owner,$actionType) {	
		var storeUrl = $owner.store.url;
		var  title;
		var  loadUrl   = "admin/article/ArticleAction!prepareEditArticle.action";
		var par = storeUrl.substring(storeUrl.lastIndexOf('?'),storeUrl.length);
		var  _records;
		var  isLoad = false;
		switch ($actionType) {
			case "articleAdd"   :
				loadUrl += par;
				title = "新增文章";
		        var win = new VAS.ArticleContentWindow({
			        id         : "artile_win",
					title      : title,
					width      : 900,
					height     : 568,
					layout	   : 'fit',
					draggable  : true,
					closable   : true,
					modal      : true,
					grid 	   : $owner,
					formUrl    : $action,
					loadUrl    : loadUrl,
					exParams   : par,
					actionType : $actionType
				}).show();	
				win.loadForm();		
				break;
				
			case "articleEdit"  :
				$owner = this.getOwnerCt($owner);
			 	_records = $owner.getSelectionModel().getSelections();   	
			 	if (typeof(_records)==='undefined'||_records.length==0) {
			 		Ext.Msg.alert('提示','您没有选择数据');
			 		return;
			 	} else if (typeof(_records)==='object' && _records.length>1) {
			 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
			 		return;
			 	}
			 	var _postData    = {};
				_postData.items  = [];
				for (var i=0;i<_records.length;i++) {
					var  _record;
					_record=_records[i];		 
					_postData.items.push(_record.data);				
				}			 	
				title     = "修改文章";
	  		    Ext.Ajax.request({
					   url    : loadUrl,
					   method : "POST",
					   params : {tbarId:$tbarId,data:Ext.encode(_postData)},					   
					   success: function(response) {
					   	   //检查session是否过期
			    		   checkTimeOut(response);
						   var responseObj = Ext.util.JSON.decode(response.responseText);
						   if(responseObj.success) {
						       var win = new VAS.ArticleContentWindow({
							        id         : "artile_win",
									title      : title,
									width      : 900,
									height     : 568,
									layout	   : 'fit',
									draggable  : true,
									closable   : true,
									modal      : true,
									grid 	   : $owner,
									formUrl    : $action,
									loadUrl    : loadUrl,
									exParams   : par,
									postData   : _postData,
									actionType : $actionType
								}).show();	
								win.loadForm();
						   } else {
						   		alertFailure(responseObj);
						   }
					   }, failure: function(response) {
							Ext.Msg.alert('提示','服务器异常！');
					   }
			   	});		
				break;
				
			case "articleArchiveEdit"  :
				loadUrl   = "admin/articlearchive/ArticleArchiveAction!prepareEditArticle.action";
				$owner = this.getOwnerCt($owner);
			 	_records = $owner.getSelectionModel().getSelections();   	
			 	if (typeof(_records)==='undefined'||_records.length==0) {
			 		Ext.Msg.alert('提示','您没有选择数据');
			 		return;
			 	} else if (typeof(_records)==='object' && _records.length>1) {
			 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
			 		return;
			 	}
			 	var _postData    = {};
				_postData.items  = [];
				for (var i=0;i<_records.length;i++) {
					var  _record;
					_record=_records[i];		 
					_postData.items.push(_record.data);				
				}			 	
				title     = "修改归档文章";
	  		    Ext.Ajax.request({
					   url    : loadUrl,
					   method : "POST",
					   params : {tbarId:$tbarId,data:Ext.encode(_postData)},					   
					   success: function(response) {
					   	   //检查session是否过期
			    		   checkTimeOut(response);
						   var responseObj = Ext.util.JSON.decode(response.responseText);
						   if(responseObj.success) {
						       var win = new VAS.ArticleContentWindow({
							        id         : "artile_win",
									title      : title,
									width      : 900,
									height     : 568,
									layout	   : 'fit',
									draggable  : true,
									closable   : true,
									modal      : true,
									grid 	   : $owner,
									formUrl    : $action,
									loadUrl    : loadUrl,
									exParams   : par,
									postData   : _postData,
									actionType : $actionType
								}).show();	
								win.loadForm();
						   } else {
						   		alertFailure(responseObj);
						   }
					   }, failure: function(response) {
							Ext.Msg.alert('提示','服务器异常！');
					   }
			   	});		
				break;
				
			case "articleKeyFilterEdit"  :
				loadUrl   = "admin/keyfilter/KeyFilterAction!prepareEditArticle.action";
				$owner = this.getOwnerCt($owner);
			 	_records = $owner.getSelectionModel().getSelections();   	
			 	if (typeof(_records)==='undefined'||_records.length==0) {
			 		Ext.Msg.alert('提示','您没有选择数据');
			 		return;
			 	} else if (typeof(_records)==='object' && _records.length>1) {
			 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
			 		return;
			 	}
			 	var _postData    = {};
				_postData.items  = [];
				for (var i=0;i<_records.length;i++) {
					var  _record;
					_record=_records[i];		 
					_postData.items.push(_record.data);				
				}			 	
				title     = "修改文章";
	  		    Ext.Ajax.request({
					   url    : loadUrl,
					   method : "POST",
					   params : {tbarId:$tbarId,data:Ext.encode(_postData)},					   
					   success: function(response) {
					   	   //检查session是否过期
			    		   checkTimeOut(response);
						   var responseObj = Ext.util.JSON.decode(response.responseText);
						   if(responseObj.success) {
						       var win = new VAS.ArticleContentWindow({
							        id         : "artile_win",
									title      : title,
									width      : 900,
									height     : 568,
									layout	   : 'fit',
									draggable  : true,
									closable   : true,
									modal      : true,
									grid 	   : $owner,
									formUrl    : $action,
									loadUrl    : loadUrl,
									exParams   : par,
									postData   : _postData,
									actionType : $actionType
								}).show();	
								win.loadForm();
						   } else {
						   		alertFailure(responseObj);
						   }
					   }, failure: function(response) {
							Ext.Msg.alert('提示','服务器异常！');
					   }
			   	});		
				break;		
		
			case "articlepreview"  :
				$owner = this.getOwnerCt($owner);
			 	_records = $owner.getSelectionModel().getSelections();   	
			 	if (typeof(_records)==='undefined'||_records.length==0) {
			 		Ext.Msg.alert('提示','您没有选择数据');
			 		return;
			 	} else if (typeof(_records)==='object' && _records.length>1) {
			 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
			 		return;
			 	}
			 	loadUrl   = "admin/article/ArticleAction!prepareViewArticle.action";
			 	loadUrl += par;
			 	var par = storeUrl.substring(storeUrl.lastIndexOf('?'),storeUrl.length);
			 	var _postData    = {};
					_postData = _records[0].data;
					_postData.content_id = _postData.id;	// 后台action中id的名字为content_id
				title     = "查看文章";
				var win = new VAS.ArticleContentWindow({
				    id         : "artile_win",
					title      : title,
					width      : 900,
					height     : 558,
					layout	   : 'fit',
					draggable  : true,
					closable   : true,
					modal      : true,
					grid 	   : $owner,
					formUrl    : $action,
					loadUrl    : loadUrl,
					exParams   : par,
					postData   : _postData,
					actionType : $actionType
				}).show();	
				win.loadForm();
				break;
				
			case "articlePreviewHdByMonitor"  :	
				$owner = this.getOwnerCt($owner);
				_records = $owner.getSelectionModel().getSelections();   	
			 	if (typeof(_records)==='undefined'||_records.length==0) {
			 		Ext.Msg.alert('提示','您没有选择数据');
			 		return;
			 	} else if (typeof(_records)==='object' && _records.length>1) {
			 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
			 		return;
			 	}
				var _postData    = {};
				_postData = _records[0].data;
			  		    Ext.Ajax.request({
							   url    : 'admin/article/ArticleAction!articleViewHdByMonitor.action',
							   method : "POST",
							   params : {id : _postData.id},					   
							   success: function(response) {
							   	   //检查session是否过期
			    				   checkTimeOut(response);
								   var responseObj = Ext.util.JSON.decode(response.responseText);
								   if(responseObj.success) {
									   eval(responseObj.msg);
								   } else {
								   		alertFailure(responseObj);
								   }
							   }, failure: function(response) {
									Ext.Msg.alert('提示','服务器异常！');
							   }
					   });	
			  	break;
			  	
			case "articlePreviewSdByMonitor"  :	
				$owner = this.getOwnerCt($owner);
				_records = $owner.getSelectionModel().getSelections();   	
			 	if (typeof(_records)==='undefined'||_records.length==0) {
			 		Ext.Msg.alert('提示','您没有选择数据');
			 		return;
			 	} else if (typeof(_records)==='object' && _records.length>1) {
			 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
			 		return;
			 	}
				var _postData    = {};
				_postData = _records[0].data;
			  		    Ext.Ajax.request({
							   url    : 'admin/article/ArticleAction!articleViewSdByMonitor.action',
							   method : "POST",
							   params : {id : _postData.id},					   
							   success: function(response) {
							   	   //检查session是否过期
			    				   checkTimeOut(response);
								   var responseObj = Ext.util.JSON.decode(response.responseText);
								   if(responseObj.success) {
									   eval(responseObj.msg);
								   } else {
								   		alertFailure(responseObj);
								   }
							   }, failure: function(response) {
									Ext.Msg.alert('提示','服务器异常！');
							   }
					   });	
			  	break;
			  	
			default :
				break;
		}

		 this.callback();
	},
	
    configAddForm : function($action,$tbarId,$owner,$actionType){
		Ext.Ajax.request({
			url     : $action, 
			method  : 'POST',
		    params  : {tbarId:$tbarId},
			success : function($response){
				//检查session是否过期
			    checkTimeOut($response);
				var responseObj = Ext.util.JSON.decode($response.responseText);
				 if(responseObj.success) {
						var _res=Ext.decode($response.responseText);
						_res.record={};
						_res.tbarId=$tbarId;
						_res.actionType=$actionType;
						var newWin=new VAS.DynamicEditFormWindow({
					        id      :  _res.win.id,
							title   :  _res.win.title,
							width   :  _res.win.width,
							height  :  _res.win.height,			
							data    :  _res,
							tbarId  :  $tbarId,
							grid    :  $owner,
							actionType   :  'add'
						});
						newWin.show();					 	
				 }else{
				 		alertFailure(responseObj);
				 }
			},
			failure:function(){
				Ext.Msg.alert('提示','服务器异常！');
			},
		    params:{tbarId:$tbarId,id:$owner.store.baseParams.id}});
	},
	
	/**
	 * 发送审核 推荐
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
	articleAudit  : function ($action,$tbarId,$owner,$actionType){
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	}
	 	var _postData    = {};
		_postData.items  = [];
		for (var i=0;i<_records.length;i++) {
			var  _record;
			_record=_records[i];		 
			_postData.items.push(_record.data);				
		}
	    Ext.Ajax.request({
			   url    : $action,
			   method : "POST",
			   params  : {tbarId:$tbarId,data:Ext.util.JSON.encode(_postData)},				   
			   success: function(response) {
			   		//检查session是否过期
			    	checkTimeOut(response);
				   var responseObj = Ext.util.JSON.decode(response.responseText);
				   if (responseObj.success) {
				   		if(responseObj.msg == '' || responseObj.msg == undefined){
							responseObj.msg = '成功';
						}
				   		Ext.Msg.alert('提示', responseObj.msg,function(bt){
					   		$owner.store.reload();
				   		});
				   } else {
				   		alertFailure(responseObj);
				   }
			   }, failure: function(response) {
					Ext.Msg.alert('提示','服务器异常！');
			   }
	   });			
		 this.callback();
	},
	
	/**
	 * 模板导入
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
    importTemplate : function($action,$tbarId,$owner){
	    var _from = new Ext.form.FormPanel({
			width         : 380,
	        frame         : true,
	        fileUpload    : true,
	        layout        : "form",
			minButtonWidth: 40,
	        defaults: {
	            anchor: '95%',
	            allowBlank: false,
	            msgTarget: 'side'
	        },					
			buttonAlign   : 'right',		            
	        items         : [{
		        	xtype           : 'panel',
		        	height          : 20
		        },{
					xtype           : 'fileuploadfield',
					hideLabel       : true,
					buttonText      : '浏览...',
					blankText       : "请选择上传文件",
					width           : 200,
					id  			: "file",
					name			: "file"			            
		        }]
		})
		var  upWin = new  VAS.BasicWindow({
		        id         : "upload",
				title      : "上传文件",
				iconCls    : 'icon-upload',
		        width      : 380,
		        height     : 150,
				minHeight  : 100,
				stateful   : false,			
				draggable  : true,
				closable   : true,
				modal      : true,
				layout     : 'fit',
				items      : [_from],
	            buttons : [{
			       id      : 'uploadBt' ,
			       text    : '上传',
			       handler : function () {
		                if(_from.getForm().isValid()){
			                _from.getForm().submit({
			                    url       : $action,
			                    waitMsg   : '正在上传 ...',
			                    success   : function(form, action){
			                    	if(action.result.msg == '' || action.result.msg == undefined){
			                    		action.result.msg = '成功';
			                    	}
			                    	Ext.Msg.alert("提示",action.result.msg,function(bt){
			                    		upWin.close();
			                    		$owner.store.reload();
										/**
										 * 增加模板树的刷新 2010-08-05 by 903820
										 */									
										if (session) {
											var remoteTree = session.get("remoteTree");
											if (typeof remoteTree != undefined && remoteTree != null) {
												remoteTree.getRootNode().reload();
											}
										}
			                    	});
			                    },
								failure   : function(form,action){
									if(action.failureType == Ext.form.Action.CLIENT_INVALID){
										Ext.Msg.alert('提示','输入的信息不符合规格，请按照提示重新输入！');
									}else{
										if(action.result.msg == '' || action.result.msg == undefined){
											action.result.msg = '失败';
										}
										Ext.Msg.alert("提示",action.result.msg);
									}
								}
			                });
		                }
			       }
			    },{
			       text    : '关闭',
			       handler : function(){
						upWin.close();
			       }
			    }]			
			}).show();
			 this.callback();
    },	
    
	/**
	 * 模板导出
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
    exportTemplate	: function($action,$tbarId,$owner){
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	}
	 	var array = [];
		for (var i=0;i<_records.length;i++) {
			array.push(_records[i].get("id"));
		}	 	
		var  iframe = document.getElementById("downloadFrame");
		iframe.src = $action+"&id="+array.toString();
	 	this.callback();	
    },
    /**
     * 列表导出
     * @param {} $action
     * @param {} $tbarId
     * @param {} $owner
     */
    exportList	: function($action,$tbarId,$owner){
		var baseParams = $owner.store.baseParams;
		// $owner.store.searchPanelId这个属性在VAS.DynamicQueryWindow中定义赋值
		baseParams.searchPanelId = $owner.store.searchPanelId;
		var params="";
	    for(var prop in baseParams){
			var param="";
			if(prop !== 'start' && prop !== 'limit' ){
				param=prop.replace(/(^\s+)|(\s+$)/g,"")+"="+baseParams[prop];	
				params=params+"&"+param;
			}
		}
		params = params + '&start=0&limit=0';
		var url = $action+'?viewEventId='+$tbarId+params;
		url=encodeURI(encodeURI(url));
		var  iframe = document.getElementById("downloadFrame");
		iframe.src = url
	 	this.callback();
    },
	/**
	 * 导出
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
    download	: function($action,$tbarId,$owner){
		document.getElementById("downloadFrame").src = $action;
	 	this.callback();	
    },
 	/**
	 * 带参数的导出
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */   
    downloadByParam	: function($action,$tbarId,$owner){
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	}
	 	if (typeof(_records)==='object' && _records.length>1) {
	 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
	 		return;
	 	}
	 	var param = Ext.urlEncode(_records[0].data);
		var  iframe = document.getElementById("downloadFrame");
		iframe.src = $action+"&" + param ;
	 	this.callback();	
    },
    
    
	/**
	 * 推荐/取消
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
    recommandTemplate	: function($action,$tbarId,$owner){
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	}
	 	var _postData    = {};
		_postData.items  = [];
		for (var i=0;i<_records.length;i++) {
			var  _record;
			_record=_records[i];		 
			_postData.items.push(_record.data);				
		}
	    Ext.Ajax.request({
			   url    : $action,
			   method : "POST",
			   params  : {tbarId:$tbarId,data:Ext.util.JSON.encode(_postData)},				   
			   success: function(response) {
			   		//检查session是否过期
			    	checkTimeOut(response);
				   var responseObj = Ext.util.JSON.decode(response.responseText);
				   if (responseObj.success) {
				   		if(responseObj.msg == '' || responseObj.msg == undefined){
							responseObj.msg = '成功';
						}
				   		Ext.Msg.alert('提示', responseObj.msg,function(bt){
				   			$owner.store.reload();
				   		});
				   } else {
				   		alertFailure(responseObj);
				   }
			   }, failure: function(response) {
					Ext.Msg.alert('提示','服务器异常！');
			   }
	   });			
		
	 this.callback();	
    
    },
    
    /**
     * 模板预览
     * @param {} $action
     * @param {} $tbarId
     * @param {} $owner
     */
    viewTemplate	: function($action,$tbarId,$owner){
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if (typeof(_records)==='object' && _records.length>1) {
	 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
	 		return;
	 	}
	 	var _postData    = {};
		_postData.items  = [];
		for (var i=0;i<_records.length;i++) {
			var  _record;
			_record=_records[i];		 
			_postData.items.push(_record.data);				
		}
	    Ext.Ajax.request({
			   url    : $action,
			   method : "POST",
			   params : {tbarId:$tbarId,data:Ext.encode(_postData)},					   
			   success: function(response) {
			   		//检查session是否过期
			    	checkTimeOut(response);
				   var responseObj = Ext.util.JSON.decode(response.responseText);
				   if (responseObj.success) {
				   		if (responseObj.imgUrl &&　responseObj.imgUrl !="") {
							var  imgWin = new  VAS.BasicWindow({
						        id         : "imgWin",
								title      : "模板预览",
						        width      : 900,
						        height     : 700,
								stateful   : false,			
								draggable  : true,
								closable   : true,
								modal      : true,
								autoScroll : true,
								html       : "<img width=880 height=660 src ="+responseObj.imgUrl+">"
							}).show();
				   		} else {
				   			Ext.Msg.alert('提示','预览图片不存在！');
				   		}
				   } else {
				   		alertFailure(responseObj);
				   }
			   }, failure: function(response) {
					Ext.Msg.alert('提示','服务器异常！');
			   }
	   });	
	  
     this.callback();
    },
	
	 roleWin : function($action,$tbarId,$owner,$actionType){
	    
	    var _record;
	 	if($actionType==='roleEdit'){
	 	  var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if (typeof(_records)==='object' && _records.length>1) {
	 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
	 		return;
	 	 }
	 	  _record=_records[0];
	 	}	 	
	 	
	 	var _title=$actionType==='roleEdit'?'角色修改':'角色新增'
	 	
// alert(1);
	 	
	    var newWin=new VAS.RoleWin({
//	    	manager:wgroup,
	    	title:_title,
			width      : 500,
			height     : 500,
			layout	   : 'fit',
			draggable  : true,
			closable   : true,
			modal      : true,
			record: _record
			,grid:$owner,
			actionType:$actionType
		});		
			
// debugger
		  newWin.show();	
// alert(2);
// Ext.WindowMgr.each(function(win){
// alert(win.lastZIndex);
// });
		  
		  if($actionType=='roleEdit'){
		  newWin.loadRecord();
		   }
		   
		   this.callback();
	}	
				
	,grid : function($action,$tbarId,$owner,$actionType){
		var _this=this;
		var _record;
		 	
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if (typeof(_records)==='object' && _records.length>1) {
	 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
	 		return;
	 	 }
	 	  _record=_records[0];
	 
	 	var postdata=_record.data;
	 	filter=postdata;
	   	AjaxDelegate($action, this.gridCallback, postdata,'return','');	
	 	
		 this.callback();
	},
				
	gridCallback:function($reponse){
		var formPanel = $reponse.wins[0].formPanel;
		if(typeof formPanel == 'undefined'){
			 var newWin=new VAS.DynamicGridWindow({
				draggable  : true,
				closable   : true,
				modal      : true	
				,title:$reponse.wins[0].title
				,height:330
				,width:$reponse.wins[0].width
				,gridPanel:$reponse.wins[0].gridPanel,
				gridPanelParams:filter			
			});	
		}else{
			var newWin=new VAS.DynamicQueryGridWin({
				draggable  : true,
				closable   : true,
				modal      : true	
				,title		:	$reponse.wins[0].title
				,height		:	$reponse.wins[0].height
				,width		:	$reponse.wins[0].width
				,formPanel	:	$reponse.wins[0].formPanel
				,gridPanel	:	$reponse.wins[0].gridPanel
				,gridPanelParams:	filter			
			});	
		}
		  newWin.show();
		  filter={};
	
	}
	,openURL:function($action,$tbarId,$owner,$actionType){
		_records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if (typeof(_records)==='object' && _records.length>1) {
	 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
	 		return;
	 	}
	 	var _postData    = {};
		_postData.items  = [];
		for (var i=0;i<_records.length;i++) {
			var  _record;
			_record=_records[i];	
			_postData.items.push(_record.data);				
		}
	 	
		title     = "打开链接信息";
		loadUrl   = "";
		saveUrl   = "";
		var viewUrl="";
		var width=400;
		var height=650;
		var win ;
			win = new VAS.OpenURLWindow({
				title      : title,
				width      : width,
				height     : height,
				draggable  : true,
				closable   : true,
				modal      : true,
				grid 	   : $owner,
				formUrl    : $action,
				loadUrl    : $action,
				postData   : _record.data,
				saveUrl:saveUrl
			   ,viewUrl:$action
				
			}).show();	
			this.callback();
	 	
	}
	,audit:function($action,$tbarId,$owner,$actionType){

		_records = $owner.getSelectionModel().getSelections();   	
			 	if (typeof(_records)==='undefined'||_records.length==0) {
			 		Ext.Msg.alert('提示','您没有选择数据');
			 		return;
			 	} else if (typeof(_records)==='object' && _records.length>1) {
			 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
			 		return;
			 	}
			 	
			 	var _postData    = {};
				_postData.items  = [];
				for (var i=0;i<_records.length;i++) {
					var  _record;
					_record=_records[i];		 
					_postData.items.push(_record.data);				
				}			 	
				title     = "审核";
				loadUrl   = "admin/audit/auditRecord!prepareViewArticle.action";
				saveUrl   = "admin/audit/auditRecord!";
				
				var viewUrl="";
				var width=910;
				var height=650;
				var win ;
				if($actionType==="viewAuditContent"){
					 viewUrl="admin/audit/auditRecord!viewIdea.action";
		         	 title     = "查看审核意见";
		         	 
		         	win = new VAS.AuditOpinionWindow({
						title      : title,
						draggable  : true,
						closable   : true,
						modal      : true,
						grid 	   : $owner,
						formUrl    : $action,
						loadUrl    : loadUrl,
						postData   : _record.data,
						saveUrl:saveUrl
					   ,viewUrl:viewUrl
		         	 }).show();
		         	 
				}else{
					win = new VAS.AuditWindow({
						title      : title,
						width      : width,
						height     : height,
	//					layout	   : 'fit',
						draggable  : true,
						closable   : true,
						modal      : true,
						grid 	   : $owner,
						formUrl    : $action,
						loadUrl    : loadUrl,
						postData   : _record.data,
						saveUrl:saveUrl
					   ,viewUrl:viewUrl
						
					}).show();	
					win.loadKeyFilterReport();
					
				}

				
				if($actionType!=="audit"){
					win.items.itemAt(0).getForm().findField('idea').setValue(_record.get('idea')); 
				}
		this.callback();
	}

	,callback:function(){
		
		  Global.queue.complete('click_tbar');
		
	},
	gridCommit : function($action,$tbarId,$owner){
    	var sd = $owner.store.data;
	 	var _postData    = {};
		_postData.items  = [];
		for (var i=0;i<sd.length;i++) {
			_postData.items.push(sd.items[i].data);				
		}
        Ext.Ajax.request({
			url     : $action,
			success : function(response, options) {
		   		//检查session是否过期
		    	checkTimeOut(response);				
				var responseObj = Ext.util.JSON.decode(response.responseText);
				if (responseObj.success) {
					if(responseObj.msg == '' || responseObj.msg == undefined){
						responseObj.msg = '成功';
					}
					Ext.MessageBox.alert('提示', responseObj.msg);
				}else{
					alertFailure(responseObj);
				}
			},
			failure : function(response, options) {
				Ext.Msg.alert('提示','服务器异常！');
			},
			params  : {tbarId:$tbarId,data:Ext.util.JSON.encode(_postData)}
		})	    
		
	 this.callback();	
    
    },
	releaseTime : function($action,$tbarId,$owner){
    	var sd = $owner.store.data;
	 	var _postData    = {};
		_postData.defaultTime=sd.items[0].data.timeValue;
		_postData.oneTime=sd.items[1].data.timeValue;
		_postData.twoTime=sd.items[2].data.timeValue;
		
        Ext.Ajax.request({
			url     : $action,
			success : function(response, options) {
		   		//检查session是否过期
		    	checkTimeOut(response);				
				var responseObj = Ext.util.JSON.decode(response.responseText);
				if (responseObj.success) {
					if(responseObj.msg == '' || responseObj.msg == undefined){
						responseObj.msg = '成功';
					}
					Ext.MessageBox.alert('提示', responseObj.msg);
					$owner.store.reload();
				}else{
					alertFailure(responseObj);
				}
			},
			failure : function(response, options) {
				Ext.Msg.alert('提示','服务器异常！');
			},
			params  : {tbarId:$tbarId,defaultTime:_postData.defaultTime,oneTime:_postData.oneTime,twoTime:_postData.twoTime}
		});	    
		
	 this.callback();	
    
    }
    
    ,setCls:function(){
    	
    	var portal=Ext.getCmp('std-panel');
    	var tbars=portal.tbar; 	
    
    	Ext.each(tbars.items.items,function(tbar){
    	   if(typeof(tbar)!='undefined'){
    	    tbar.setDisabled(false);
    	     tbar.removeClass("bgRed");
    	   }
    	 })
    	 	this.addClass("bgRed");
    	 	this.setDisabled(true);
   
    },
    
    /**
     * 设置桌面快捷方式
     */
    showShourCut : function(){
		showShourCut();		// 调用VAS.ShortcutSetting中的方法
	},
    
	/**
	 * 启用皮肤
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
	 startSkin	: function($action,$tbarId,$owner){
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if (typeof(_records)==='object' && _records.length>1) {
	 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
	 		return;
	 	}
	 	var _postData    = {};
		_postData.items  = [];
		for (var i=0;i<_records.length;i++) {
			var  _record;
			_record=_records[i];		 
			_postData.items.push(_record.data);				
		}
	    Ext.Ajax.request({
			   url    : $action,
			   method : "POST",
			   params : {tbarId:$tbarId,data:Ext.encode(_postData)},					   
			   success: function(response) {
			   		//检查session是否过期
			    	checkTimeOut(response);			   	
				   var responseObj = Ext.util.JSON.decode(response.responseText);
				   if (responseObj.success) {
				   		if(responseObj.msg == '' || responseObj.msg == undefined){
							responseObj.msg = '成功';
						}
				   		Ext.Msg.alert('提示', responseObj.msg,function(bt){
					   		$owner.store.reload();
				   		});
				   } else {
				   		alertFailure(responseObj);
				   }
			   }, failure: function(response) {
					Ext.Msg.alert('提示','服务器异常！');
			   }
	   	});	
	  
     	this.callback();
	},	
	    
	/**
	 * 皮肤导出
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
    exportSkin	: function($action,$tbarId,$owner){
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if (typeof(_records)==='object' && _records.length>1) {
	 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
	 		return;
	 	}
		var  ifame = document.getElementById("downloadFrame");
		ifame.src = $action+"&sid="+_records[0].get("sid");
	 	this.callback();	
    },
    
	/**
	 * 一对多管理
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
    childmanage	: function($action,$tbarId,$owner){
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if (typeof(_records)==='object' && _records.length>1) {
	 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
	 		return;
	 	}
	 	var _postData    = {};
		_postData.items  = [];
		for (var i=0;i<_records.length;i++) {
			var  _record;
			_record=_records[i];		 
			_postData.items.push(_record.data);				
		}    
	    Ext.Ajax.request({
		   url    : $action,
		   method : "POST",
		   params  : {data:Ext.util.JSON.encode(_postData)},				   
		   success: function(response) {
		   		//检查session是否过期
		    	checkTimeOut(response);		   	
			   var responseObj = Ext.util.JSON.decode(response.responseText);
			   if (responseObj.success) {
					var win = new VAS.CommQueryGridWin({
						popUp : {
							//compositeSelect : _this,
							id       : "childmanageWin",
							fromForm : true,
							wins : responseObj.wins,
							grid:$owner
							
						}
					});
					win.show();					   	
			   } else {
			   		alertFailure(responseObj);
			   }
		   }, failure: function(response) {
				Ext.Msg.alert('提示','服务器异常！');
		   }
	   });	
	 	this.callback();	
    },
    
	/**
	 * 一对多管理建立关联
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
    addbyselect	: function($action,$tbarId,$owner){
    	var par = Ext.util.JSON.decode($owner.params);
    	var postParams  = {};
    	for(var p in par) {
    		postParams[p] = Ext.util.JSON.encode(par[p]);
    	}
	    Ext.Ajax.request({
		   url    : $action,
		   method : "POST",
		   params : postParams,				   
		   success: function(response) {
		   		//检查session是否过期
		    	checkTimeOut(response);		   	
			   var responseObj = Ext.util.JSON.decode(response.responseText);
			   if (responseObj.success) {
					var win = new VAS.CommQueryGridWin({
						popUp : {
							//compositeSelect : _this,
							id         : "addbyselectWin",
							event      : $owner,
							fromForm   : false,
							wins       : responseObj.wins
						}
					});
					win.show();					   	
			   } else {
			   		alertFailure(responseObj);
			   }					   	
		   }, failure: function(response) {
				Ext.Msg.alert('提示','服务器异常！');
		   }
	   });	
	 	this.callback();	
    },
    
	/**
	 * 一键获取天气
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
    SnatchWeather	: function($action,$tbarId,$owner){
    	Ext.Msg.show({
			title : '确认',
			msg : '你确定手动抓取天气吗？该操作在服务器后台运行，需要的时间大概20分钟左右，请稍后查看抓取结果。',
			buttons : {yes:'是', no:'否'},
			fn : function(btn){
					if(btn=="yes"){
					    Ext.Ajax.request({
							   url:$action,
							   success: function(response) {
							   	    //检查session是否过期
			    					checkTimeOut(response);
							   }, failure: function(response) {
								 //Ext.Msg.alert('失败','服务器异常！');
							   }
						});											
					}
				}
    	});
	 	this.callback();	
    },
    
	/**
	 * 手动根据城市id获取天气
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
    SnatchWeatherByCity	: function($action,$tbarId,$owner){
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	}
	 	var _postData    = {};
		_postData.items  = [];
		for (var i=0;i<_records.length;i++) {
			var  _record;
			_record=_records[i];		 
			_postData.items.push(_record.data);				
		}
	    Ext.Ajax.request({
			   url    : $action,
			   method : "POST",
			   params : {tbarId:$tbarId,data:Ext.encode(_postData)},					   
			   success: function(response) {
			   		//检查session是否过期
			    	checkTimeOut(response);
				   var responseObj = Ext.util.JSON.decode(response.responseText);
				   if (responseObj.success) {
				   		if(responseObj.msg == '' || responseObj.msg == undefined){
							responseObj.msg = '成功';
						}
				   		Ext.Msg.alert('提示', responseObj.msg,function(bt){
					   		$owner.store.reload();
				   		});
				   } else {
				   		alertFailure(responseObj);
				   }
			   }, failure: function(response) {
					Ext.Msg.alert('提示','服务器异常！');
			   }
	   });
	 	
	 	this.callback();	
    },
    
    /**
	 * 手动根据城市id获取城市图片
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
    SnatchCityIconByCity	: function($action,$tbarId,$owner){
	 	var _records = $owner.getSelectionModel().getSelections();  
	 	var _postData    = {};
		_postData.items  = [];
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		//Ext.Msg.alert('提示','您没有选择数据');
	 		Ext.MessageBox.confirm('提示', '确认全部抓取？', function(btn){
	 			if (btn == 'yes'){ 
	 			 Ext.Ajax.request({
	 				   url    : $action,
	 				   method : "POST",
	 				   params : {tbarId:$tbarId,data:Ext.encode(_postData)},					   
	 				   success: function(response) {
	 				   		//检查session是否过期
	 				    	checkTimeOut(response);
	 					   var responseObj = Ext.util.JSON.decode(response.responseText);
	 					   if (responseObj.success) {
	 					   		if(responseObj.msg == '' || responseObj.msg == undefined){
	 								responseObj.msg = '成功';
	 							}
	 					   		Ext.Msg.alert('提示', responseObj.msg,function(bt){
	 						   		$owner.store.reload();
	 					   		});
	 					   } else {
	 					   		alertFailure(responseObj);
	 					   }
	 				   }, failure: function(response) {
	 						Ext.Msg.alert('提示','服务器异常！');
	 				   }
	 		   });
	 		}
	 		    });
	 		  return ; 
	 	}else 
	 	{
	 		for (var i=0;i<_records.length;i++) {
				var  _record;
				_record=_records[i];		 
				_postData.items.push(_record.data);				
			}
	 	}
	    Ext.Ajax.request({
			   url    : $action,
			   method : "POST",
			   params : {tbarId:$tbarId,data:Ext.encode(_postData)},					   
			   success: function(response) {
			   		//检查session是否过期
			    	checkTimeOut(response);
				   var responseObj = Ext.util.JSON.decode(response.responseText);
				   if (responseObj.success) {
				   		if(responseObj.msg == '' || responseObj.msg == undefined){
							responseObj.msg = '成功';
						}
				   		Ext.Msg.alert('提示', responseObj.msg,function(bt){
					   		$owner.store.reload();
				   		});
				   } else {
				   		alertFailure(responseObj);
				   }
			   }, failure: function(response) {
					Ext.Msg.alert('提示','服务器异常！');
			   }
	   });
	 	
	 	this.callback();	
    },
    
    previewByMonitor : function($action,$tbarId,$owner){
		var _postData    = {};
	    Ext.Ajax.request({
			   url    : $action,
			   method : "POST",
			   params : _postData,		   
			   success: function(response) {
			   		//检查session是否过期
			    	checkTimeOut(response);
				   var responseObj = Ext.util.JSON.decode(response.responseText);
				   if(responseObj.success) {
					   eval(responseObj.msg);
				   } else {
						alertFailure(responseObj);
				   }
			   }, failure: function(response) {
					Ext.Msg.alert('提示','服务器异常！');
			   }
	   })
	},
	
	previewByMonitorWithParam : function($action,$tbarId,$owner){
	 	var _records = $owner.getSelectionModel().getSelections();   	
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if (typeof(_records)==='object' && _records.length>1) {
	 		Ext.Msg.alert('提示','每次操作只能选择一条数据');
	 		return;
	 	}
	 	var _postData    = {tbarId:$tbarId, id:_records[0].data.id, data:Ext.util.JSON.encode(_records[0].data)};
	    Ext.Ajax.request({
			   url    : $action,
			   method : "POST",
			   params: _postData,
			   success: function(response) {
			   		//检查session是否过期
			    	checkTimeOut(response);			   	
				   var responseObj = Ext.util.JSON.decode(response.responseText);
				   if(responseObj.success) {
					   eval(responseObj.msg);
				   } else {
				   		alertFailure(responseObj);
				   }
			   }, failure: function(response) {
					Ext.Msg.alert('提示','服务器异常！');
			   }
	   })
	},
	
    rowUp : function($action,$tbarId,$owner){
    	
		var _this=this;
		var _postData   =  {};
		_postData.selectObj = {};
		
		var _records = $owner.getSelectionModel().getSelections();  
		if(_records.length >1){
			Ext.Msg.alert('提示','只能选择一条记录');
			return ;
		}
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if(typeof(_records)==='object' && _records.length>=1){
			_postData.selectObj = _records[0].data;
			_postData.baseParams = $owner.store.baseParams;
	        Ext.Ajax.request({
				url : $action,
				params: {data : Ext.util.JSON.encode(_postData)},
				success : function(response, options) {
			   		//检查session是否过期
			    	checkTimeOut(response);
					var responseObj = Ext.util.JSON.decode(response.responseText);
					if(responseObj.success){
						$owner.store.reload();
					}else{
						alertFailure(responseObj);
					}
				},
				failure : function(response, options) {
					Ext.Msg.alert('提示','服务器异常！');
				}
			})
	 	}
	 	this.callback();
	
	},
	
	rowDown : function($action,$tbarId,$owner){
		var _this=this;
		var _postData   =  {};
		_postData.selectObj = {};
		
		var _records = $owner.getSelectionModel().getSelections();  
		if(_records.length >1){
			Ext.Msg.alert('提示','只能选择一条记录');
			return ;
		}
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if(typeof(_records)==='object' && _records.length>=1){
			_postData.selectObj = _records[0].data;
			_postData.baseParams = $owner.store.baseParams;

	        Ext.Ajax.request({
				url : $action,
				params: {data : Ext.util.JSON.encode(_postData)},
				success : function(response, options) {
			   		//检查session是否过期
			    	checkTimeOut(response);					
					var responseObj = Ext.util.JSON.decode(response.responseText);
					if(responseObj.success){
						$owner.store.reload();
					}else{
						alertFailure(responseObj);
					}
				},
				failure : function(response, options) {
					Ext.Msg.alert('提示','服务器异常！');
				}
			})
	 	}
	 	this.callback();
	},
	
	rowTop : function($action,$tbarId,$owner){
		var _this=this;
		var _postData   =  {};
		_postData.selectObj = {};
		
		var _records = $owner.getSelectionModel().getSelections();  
		if(_records.length >1){
			Ext.Msg.alert('提示','只能选择一条记录');
			return ;
		}
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if(typeof(_records)==='object' && _records.length>=1){
			_postData.selectObj = _records[0].data;
			_postData.baseParams = $owner.store.baseParams;
	        Ext.Ajax.request({
				url : $action,
				params: {data : Ext.util.JSON.encode(_postData)},
				success : function(response, options) {
			   		//检查session是否过期
			    	checkTimeOut(response);					
					var responseObj = Ext.util.JSON.decode(response.responseText);
					if(responseObj.success){
						$owner.store.reload();
					}else{
						alertFailure(responseObj);
					}
				},
				failure : function(response, options) {
					Ext.Msg.alert('提示','服务器异常！');
				}
			})
	 	}
	 	this.callback();
	},
	
	rowBottom : function($action,$tbarId,$owner){
		var _this=this;
		var _postData   =  {};
		_postData.selectObj = {};
		
		var _records = $owner.getSelectionModel().getSelections();  
		if(_records.length >1){
			Ext.Msg.alert('提示','只能选择一条记录');
			return ;
		}
	 	if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
	 	} else if(typeof(_records)==='object' && _records.length>=1){
		_postData.selectObj = _records[0].data;
		_postData.baseParams = $owner.store.baseParams;
	        Ext.Ajax.request({
				url : $action,
				params: {data : Ext.util.JSON.encode(_postData)},
				success : function(response, options) {
			   		//检查session是否过期
			    	checkTimeOut(response);					
					var responseObj = Ext.util.JSON.decode(response.responseText);
					if(responseObj.success){
						$owner.store.reload();
					}else{
						alertFailure(responseObj);
					}
				},
				failure : function(response, options) {
					Ext.Msg.alert('提示','服务器异常！');
				}
			})
	 	}
	 	this.callback();
	}
	,syn : function($action,$tbarId,$owner){
		var _this=this;
		_this.disable();
        Ext.Ajax.request({
			url : $action,
			timeout : 1200000,
			params:{},
			success : function(response, options) {
				//检查session是否过期
			    checkTimeOut(response);
				_this.enable();
				var responseObj = Ext.util.JSON.decode(response.responseText);
				if(responseObj.success){
			   		if(responseObj.msg == '' || responseObj.msg == undefined){
						responseObj.msg = '成功';
					}
					Ext.MessageBox.alert('提示', responseObj.msg,function(bt){
						$owner.store.reload();
					});
				}else{
					alertFailure(responseObj);
				}
			},
			failure : function(response, options) {
				_this.enable();
				Ext.Msg.alert('提示','服务器异常！');
			}
		})
	}
	
	,quickAddEdit : function($action,$tbarId,$owner){
		var window = $owner.ownerCt;
		var panel = $owner.ownerCt.dynamicFormPanel;
		if(typeof(panel) == 'object'){
			if(panel.hidden){
				panel.show();
			}else{
				panel.hide();
			}
			window.doLayout();
		}else{
			Ext.MessageBox.alert('提示','没有配置快速新增修改页面');
		}
	},
	
	
	login : function($action,$tbarId,$owner){
		    	/**
    	 * 判断$action中有没有配置按钮名称buttonTextFlag。
    	 * 如果有就把他提取出来，作为DynamicEditFormWindow的一个参数，
    	 * 实现动态配置按钮的名称
    	 */
    	var index = $action.lastIndexOf('buttonTextFlag');
    	var buttonTextFlag = '';
    	if(index != -1){
    		var urlParam = $action.substr(index);
    		var urlParamObj = Ext.urlDecode(urlParam);
    		if(typeof(urlParamObj) === 'object'){
	    		buttonTextFlag = urlParamObj.buttonTextFlag;
    		}
    	}
		Ext.Ajax.request({
			url     : $action, 
			method  : 'POST',
			success : function($response){
				//检查session是否过期
			    checkTimeOut($response);
				var responseObj = Ext.util.JSON.decode($response.responseText);
				if(responseObj.success){
						var _res        = Ext.decode($response.responseText);
						var newWin = new VAS.DynamicEditFormWindow({
					        id      :  _res.win.id,
							title   :  _res.win.title,
							width   :  _res.win.width,
							height  :  _res.win.height,			
							data    :  _res,
							tbarId  :  $tbarId,
							grid    :  $owner,
							actionType   :  'add'
							,buttonTextFlag : buttonTextFlag
						});
						newWin.show();	
				}else{
					alertFailure(responseObj);
				}
			},
			failure:function(){
				Ext.Msg.alert('提示','服务器异常！');
			}
		   });
		
	},
	
	logout : function($action,$tbarId,$owner){
		Ext.Ajax.request({
			url     : $action, 
			method  : 'POST',
			success : function($response){
				//检查session是否过期
			    checkTimeOut($response);				
				var responseObj = Ext.util.JSON.decode($response.responseText);
				if(responseObj.success){
					$owner.store.reload();
				}else{
					alertFailure(responseObj);
				}
			},
			failure:function(){
				Ext.Msg.alert('提示','服务器异常！');
			}
		   });
	}
	

	,publishBussiness : function($action,$tbarId,$owner){
		var myMask ;
	    var isPublishing=0;
	    var intervalId;
	    var _owner = $owner.ownerCt;
	    var _store = $owner.store;
	    var _this=this;
		var _records = $owner.getSelectionModel().getSelections();  
	    var _postData   =  {};
		_postData.items =  [];
		var  _record;
		for(var i=0;i<_records.length;i++){
			_record=_records[i];		 
			_postData.items.push(_record.data);				
		}
	    
	    if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','请选择要发布的对象');
	 		return;
	 	} 
	 	
		Ext.Ajax.request({
			url : $action,
		    success: function(response) {
			   var responseObj1 = Ext.util.JSON.decode(response.responseText);
			   if (responseObj1.success) {
			   		_owner.body.mask(responseObj1.msg,"x-mask-loading");
					intervalId=window.setInterval(function(){
						Ext.Ajax.request({
							url : 'admin/pub/pub!getPubStatus.action?threadId='+responseObj1.threadId,
						    success: function(response) {
						    	//检查session是否过期
			    				checkTimeOut(response);
							    var responseObj = Ext.util.JSON.decode(response.responseText);
							   	if(responseObj.isIdle){
							   		_owner.body.unmask();
							   		Ext.Msg.alert('提示', responseObj.msg);
							   		if(isPublishing == 1){
							   			isPublishing = 0;
							   			window.clearInterval(intervalId);
							   			_store.reload();
							   		}
							   } 
						   }, failure: function(response) {
								Ext.Msg.alert('提示','服务器异常！');
						   },
						   params: {}
						});
					}
					,5000);
					isPublishing=1;
			   } else {
			   		alertFailure(responseObj1);
			   }
		   }, failure: function(response) {
				Ext.Msg.alert('提示','服务器异常！');
		   },
		   params: {
				data : Ext.util.JSON.encode(_postData)
		   }
		});
	}
	/**
	 * 批量向后台提交一条或多条数据
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 * @param {} $actionType
	 */
	,batchProcess : function($action,$tbarId,$owner,$actionType){
		var _this=this;
		var _records = $owner.getSelectionModel().getSelections();  
		if (typeof(_records)==='undefined'||_records.length==0) {
	 		Ext.Msg.alert('提示','您没有选择数据');
	 		return;
		}
		var _postData   =  {};
		_postData.items =  [];
		var  _record;
		for(var i=0;i<_records.length;i++){
			_record=_records[i];		 
			_postData.items.push(_record.data);				
		}
		var msg ="您确定要执行这项操作吗?";	

	 	if(typeof(_records)==='object' && _records.length>=1){
			Ext.Msg.show({
				title : '提示',
				msg : msg,
				buttons : {yes:'是', no:'否'},
				fn : function(btn){
				    if (btn == 'yes'){
				        Ext.Ajax.request({
							url : $action,
							success : function(response, options) {
								//检查session是否过期
			    				checkTimeOut(response);
								var responseObj = Ext.util.JSON.decode(response.responseText);
								if(responseObj.success){
									$owner.store.reload();
								}else{
									alertFailure(responseObj);
								}
							},
							failure : function(response, options) {
								Ext.Msg.alert('提示','服务器异常！');
							},
							params:{tbarId:$tbarId,data:Ext.util.JSON.encode(_postData)}
						})
				   	}else{
				    	return;	
				   	}
				}
			});
	 	} 	
	 	this.callback();
	},
	 /**
	 * 不选择执行所有数据，选择后执行选择数据
	 * @param {} $action
	 * @param {} $tbarId
	 * @param {} $owner
	 */
	fechtCoreStart : function ($action,$tbarId,$owner){
		var _records = $owner.getSelectionModel().getSelections();  
	 	var _postData    = {};
		_postData.items  = [];
		if (typeof(_records)==='undefined'||_records.length==0) {
			Ext.MessageBox.confirm('提示', '确认全部抓取？', function(btn){
				if (btn == 'yes'){ 
					Ext.Ajax.request({
						url    : $action,
		 				   method : "POST",
		 				   params : {tbarId:$tbarId,data:Ext.encode(_postData)},					   
		 				   success: function(response) {
		 				   		//检查session是否过期
		 				    	checkTimeOut(response);
		 					   var responseObj = Ext.util.JSON.decode(response.responseText);
		 					   if (responseObj.success) {
		 					   		if(responseObj.msg == '' || responseObj.msg == undefined){
		 								responseObj.msg = '成功';
		 							}
		 					   		Ext.Msg.alert('提示', responseObj.msg,function(bt){
		 						   		$owner.store.reload();
		 					   		});
		 					   } else {
		 					   		alertFailure(responseObj);
		 					   }
		 				   }, failure: function(response) {
		 						Ext.Msg.alert('提示','服务器异常！');
		 				   }
					});
				}
			});
			return;
		}else{
			for (var i=0;i<_records.length;i++) {
				var  _record;
				_record=_records[i];		 
				_postData.items.push(_record.data);				
			}
		}
		Ext.Ajax.request({
			   url    : $action,
			   method : "POST",
			   params : {tbarId:$tbarId,data:Ext.encode(_postData)},					   
			   success: function(response) {
			   		//检查session是否过期
			    	checkTimeOut(response);
				   var responseObj = Ext.util.JSON.decode(response.responseText);
				   if (responseObj.success) {
				   		if(responseObj.msg == '' || responseObj.msg == undefined){
							responseObj.msg = '成功';
						}
				   		Ext.Msg.alert('提示', responseObj.msg,function(bt){
					   		$owner.store.reload();
				   		});
				   } else {
				   		alertFailure(responseObj);
				   }
			   }, failure: function(response) {
					Ext.Msg.alert('提示','服务器异常！');
			   }
	   });
	 	
	 	this.callback();
	},
	
	/**
	 * 批量转移文章
	 * @param {} action
	 * @param {} id
	 * @param {} table
	 * @autor liwen 
	 * add transfer function 2011-7-6
	 */
	transfer : function(action,id,table){
		var records = table.getSelectionModel().getSelections();
		var _postData    = {};
		_postData.items  = [];
		var  r;
		for (var i=0;i<records.length;i++) {
			r=records[i];
			_postData.items.push(r.data);	
		}
		//alert(Ext.util.JSON.encode(_postData));
	    Ext.Ajax.request({
		   url    : action,
		   method : "POST",
		   params  : {data:Ext.util.JSON.encode(_postData)},
		   success: function(response) {
		   		//检查session是否过期
		    	checkTimeOut(response);
			   var responseObj = Ext.util.JSON.decode(response.responseText);
			   if (responseObj.success) {
			   		//alert(Ext.util.JSON.encode(responseObj));
			   		// alert("success"+response.responseText);
					var win = new VAS.CommQueryGridWin({
						popUp : {
							id       : "transferWin",
							fromForm : true,
							wins : responseObj.wins,
							grid:table
						}
					});
					win.show();
			   } else {
			   		alertFailure(responseObj);
			   }
		   }, failure: function(response) {
				Ext.Msg.alert('提示','服务器异常！');
		   }
	   });	
	   this.callback();
	},
	callback:function(){
		
	},
	getOwnerCt : function(ownerCt){
		var ow = ownerCt;
		if(!ow){
			return 0;
		}
		if(ow['getSelectionModel']){
			return ow;
		}else{
			return this.getOwnerCt(ow.ownerCt);
		}
	}
	
});

Ext.reg('dynamicTbar', Ext.ux.DynamicTbar);
